package service;

import java.util.ArrayList;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import entity.Admin;
import entity.Score;
import entity.Teacher;
import mapper.ScoreMapper;

@Service
public class ScoreService {

	@Autowired
	private ScoreMapper scoreMapper;
	
	public ArrayList<Score> findAll(){
		return scoreMapper.findAll();
	}
	public String alter(Score score,HttpSession session) {
		Admin admin = (Admin)session.getAttribute("admin");
		Teacher teacher=(Teacher)session.getAttribute("teacher");
		if(admin==null&&teacher==null) {
			return "没有权限";
		}else {
			scoreMapper.alter(score);
			return "修改成功";
		}
	}
	public Score findById(Score score) {
		return scoreMapper.findById(score.getId());
	}
	public String delete(Score score,HttpSession session) {
		Admin admin = (Admin)session.getAttribute("admin");
		if(admin==null) {
			return "没有权限";
		}else {
			scoreMapper.delete(score.getId());
			return "修改成功";
		}
	}

}
